home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / novell / btrieve / status2.txt < prev   
Text File  |  1996-07-10  |  8KB  |  163 lines

  1.              
  2. Btrieve's Status 2
  3.  
  4.     Status 2 is defined in the Btrieve manual as an I/O error, i.e., an
  5. error that has occurred during disk read/write.  By nature of the problem,
  6. it is almost impossible to determine the exact cause of a status 2. 
  7. Sometimes it indicates that the file is damaged and must be recovered. 
  8. Sometimes your file is fine, but something else is wrong, such as your
  9. hardware, or a number of things you will see later in this article.  We
  10. will also discuss some preventable causes of status 2.
  11.  
  12. In general, the type of Btrieve operation that returns a status 2 can
  13. usually indicate which part of the file is corrupted, if the file is indeed
  14. corrupted. If status 2 occurs on an OPEN call, the header page of the file
  15. may be damaged.
  16.  
  17. If it is returned on a GET operation, one or more key pages for that
  18. particular key may be corrupted. If a write operation (INSERT, DELETE,
  19. UPDATE) returns a status 2, one or more key pages for any key may be
  20. damaged.  Status 2 on read or write operations may also indicate corrupted
  21. data pages.
  22.  
  23. Once a key path is corrupted, you may be able to retrieve your records
  24. using any other key path.  But, the problem still exists and will continue
  25. to exist until the file is rebuilt.  If the header page or a data page is
  26. corrupted, you probably will not have any choice but to rebuild it.
  27.  
  28. However, in all cases mentioned above, it is possible that there is a
  29. physical problem with the hard disk, where certain pages in the file can no
  30. longer be accessed.  This indicates a bad spot on the disk.  There could
  31. also be a problem with the File Allocation Table that the operating system
  32. keeps.  In the case of status 2 on a write operation, it is possible that
  33. your file is fine and you are simply out of disk space.
  34.  
  35.  
  36. Common Preventable Causes:
  37.  
  38. 1.  Overwritten Position Block:
  39.  
  40. Perhaps the most obvious cause for status 2 is an overwritten position
  41. block.  Check where in the program the position block is defined, and what
  42. variables are defined immediately before the position block.  See when,
  43. where and how these variables are accessed, to make sure the position block
  44. is not overwritten.  Moreover, be sure that after the OPEN call you do not
  45. modify the position block.
  46.  
  47. 2.  Multiple Pre-image Files for One 
  48.      Data File
  49.  
  50. Having multiple pre-image files for one data file can definitely cause
  51. problems. By default, Btrieve creates the pre-image file in the same
  52. directory as the data file.  You do want to make sure that all workstations
  53. that are accessing the same data file access the same pre-image file.
  54.  
  55. This problem may manifest itself in the form of using NetWare search
  56. mappings to find a Btrieve file.  When Btrieve opens a file, it expects the
  57. complete path\file_name, or just the file_name. Btrieve will go to the path
  58. specified to open the Btrieve file, or in the case of just the file name,
  59. Btrieve looks in the default directory for the file.  In versions prior to
  60. 5.0, if Btrieve does not find the data file in the current default
  61. directory, NetWare may find the file through one of its search mappings and
  62. be able to successfully open the file.
  63.  
  64. This can cause problems since Btrieve does not have a complete path.
  65. Specifically, on write operations, the pre-image file that Btrieve uses
  66. will be created in the current default directory.  If several users are
  67. accessing the same data file from different default directories, they could
  68. all end up with their own .PRE files.  If an operation needed to be rolled
  69. back, (flagged by the header page of the data file) the workstation would
  70. use the .PRE file it knew about, which more than likely was not the one
  71. that needed to be rolled back.  Using an old pre-image file would damage a
  72. Btrieve file.
  73.  
  74. By the same token, if you are directing your pre-image files, make sure
  75. everybody on the network specifies the same destination.  Otherwise, you
  76. will encounter the problem of multiple pre-image files.  You can direct
  77. your pre-image files using the /I option at load time.  (This feature is
  78. not available with NetWare Btrieve and Btrieve for Xenix.)
  79.  
  80. 3.  One Pre-image File for Multiple 
  81.      Data Files:
  82.  
  83. On the other hand, having one pre-image file for multiple data files could
  84. potentially cause file corruption.  Be sure that file names are unique,
  85. with different extensions.  Since Btrieve uses the .PRE extension for
  86. pre-image files, data files such as EMPLOYEE.DAT and EMPLOYEE.VAC have the
  87. same pre-image file.
  88.  
  89. 4.  Large Pre-image File Inside a 
  90.      Transaction: 
  91.  
  92. Status 2 could also be returned on a write operation inside a transaction
  93. if you do not have enough disk space for the pre-image file.  Inside a
  94. begin/end transaction operation, Btrieve appends pages to the pre-image
  95. file.  Naturally, after many write operations inside a transaction, the
  96. pre-image file can become quite large.  At this point, if an application
  97. receives an error status, most applications trap for errors and try to
  98. terminate gracefully, closing all the files along the way.  The offending
  99. pre-image file is also deleted and the space it occupied is released,
  100. making it impossible to detect that shortage of disk space was the culprit.
  101.  
  102. 5.  NetWare Flag of Btrieve Files:
  103.  
  104. On NetWare, all Btrieve files are flagged as Non-Shareable, Read/Write as
  105. they are created.  In all circumstances, you do not want to re-flag Btrieve
  106. files as Shareable.  Flagging a file Non-Shareable means asking NetWare to
  107. pay attention to the open mode of the file.  Since different "flavors" of
  108. Btrieve open files in different modes, this prevents different "flavors" of
  109. Btrieve from opening the same file and updating to it at the same time.  In
  110. some cases, this would lead to file corruption.  For example, if you flag a
  111. file as Shareable, and load Btrieve Single-User on two stations.  The file
  112. is open on both stations and updates are done to it.  Since Btrieve
  113. Single-User is not aware that the file is being shared with other
  114. workstations, it does not test for contentions or apply any locks.  It may
  115. make inappropriate modifications to the file.
  116.  
  117. 6.  User Access Rights:
  118.  
  119. In a network environment, make sure that the user has proper security
  120. rights to all files that need to be accessed.  On NetWare, if the user is
  121. opening the file in normal, accelerated, or exclusive mode, the user must
  122. have READ, WRITE and CREATE rights for the directories that contain Btrieve
  123. files (including a transaction file, if applicable).
  124.  
  125. 7.  Using TTS and Btrieve for DOS 
  126.      3.1 Networks:
  127.  
  128. Status 2 may also come back with the following combination:  multiple
  129. stations using Btrieve for DOS 3.1 Networks access the same files on
  130. NetWare 2.10 or greater, the Transactional Tracking System feature is
  131. activated, and your file is flagged as Transactional.  Keep in mind that
  132. TTS is locking every page that it accesses.  This includes the first page
  133. of the file, also known as the header page.  If another station tries to
  134. access the same file, Btrieve sees that the header page has been locked,
  135. but that the lock was not enforced by Btrieve. Btrieve will return status
  136. 2.
  137.  
  138. Note that the file is not damaged in any way.  When the first station
  139. closes the file, the second station will be able to access it.  Therefore,
  140. when you use Btrieve for DOS 3.1 Networks, you should flag your files as
  141. non-transactional and let Btrieve handle file integrity with its
  142. pre-imaging.  If you are using NetWare Btrieve, then you have the choice of
  143. using NetWare's TTS (if available on your version of NetWare) or Btrieve's
  144. pre-imaging for file integrity. 
  145.  
  146. 8.  Using NetWare v2.12, NetWare 
  147.      Btrieve v4.11 and Btrieve 
  148.      Transaction:
  149.  
  150. Last, but not least, if you are using NetWare Btrieve v4.11a on NetWare
  151. 2.12, you may receive status 2 inserting records inside a Btrieve
  152. transaction.  This problem has been addressed in version 5.0 of NetWare
  153. Btrieve and NetWare 2.15.
  154.  
  155. The above information was intended to give some additional insights into
  156. the difficulty of diagnosing status 2 and some known causes.  Since each
  157. case may be slightly different, only the most common things have been
  158. covered.  If you are experiencing status 2 and none of the above seems to
  159. apply, please contact Novell DPD technical support.
  160.  
  161.                
  162.  
  163.